package com.platform.comm.common.batch.processor;


import com.platform.vo.ImportDto;
import com.platform.comm.common.batch.ComBatchContext;
import org.springframework.batch.item.ItemProcessor;

/**
 * 批量导入重复性验证
 * @author Tommy
 */
public class ImportDataRepeatProcessor implements ItemProcessor<ImportDto, ImportDto> {

    private ComBatchContext context;

    public ImportDataRepeatProcessor(ComBatchContext context) {
        this.context = context;
    }

    @Override
    public ImportDto process(ImportDto item) {
        try {
            if (!item.isFlag()) {
                return item;
            }
            item = context.repeatImport(item);
        } catch (Exception ex) {
            item.setFlag(false);
            item.setErrMsg(ex.getMessage());
        }
        return item;
    }
}
